<template>
    <div class="foot-tab-wrap">
        <van-tabbar>
            <van-tabbar-item  v-for="(item, index) in navList" :key="index" :name="item.pathName"  @click="handleToPage(item)">
                <div :class="['name', current === index ? 'on' : '']">{{ item.title }}</div>
                <template #icon>
                    <img class="icon" :src="current === index ? item.iconOn : item.icon" />
                </template>
            </van-tabbar-item>
        </van-tabbar>
        <!-- <div 
        v-for="(item, index) in navList"
        :key="index"
        @click="handleToPage(item)"
        class="tab-li active-btn" >
            <img class="icon" :src="current === index ? item.iconOn  : item.icon" alt="">
            <div :class="['name', current === index ? 'on' : '']" >{{ item.title }}</div>
        </div> -->
    </div>
</template>

<script>
import {
    tabIcon1,
    tabIcon1s,
    tabIcon2,
    tabIcon2s,
    tabIcon3,
    tabIcon3s,
    tabIcon4,
    tabIcon4s,
    tabIcon5,
    tabIcon5s
} from '@/tool/static-img';
export default {
    props: {
        current: {
            type: Number,
            default: 0,
        }
    },
    data() {
        return {
            active:'home',
            navList: [{
                title: '首页',
                pathName: 'home',
                icon: tabIcon1,
                iconOn: tabIcon1s
            },
            // {
            //     title: '商城',
            //     pathName: 'goods',
            //     icon: tabIcon5,
            //     iconOn: tabIcon5s
            // },
            {
                title: '本地商户',
                pathName: 'store',
                icon: tabIcon2,
                iconOn: tabIcon2s
            },
            {
                title: '购物车',
                pathName: 'cart',
                icon: tabIcon3,
                iconOn: tabIcon3s
            },
            {
                title: '我的',
                pathName: 'mine',
                icon: tabIcon4,
                iconOn: tabIcon4s
            }]
        }
    },
    methods: {
        handleToPage(item) {
            this.$router.replace({
                name: item.pathName
            })
        }
    }

}
</script>

<style lang="scss">
.foot-tab-wrap {
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 9999 !important;
    display: flex;
    align-items: center;
    width: 100%;
    padding-bottom: calc(constant(safe-area-inset-bottom));
    padding-bottom: calc(env(safe-area-inset-bottom));
    border-top: 1px solid #E3E3E3;
    background-color: #ffffff;
    box-sizing: content-box;

    .tab-li {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        flex: 1;
        padding: 0.06rem 0;



    }
    .icon {
            width: 0.48rem;
            height: 0.48rem;
            margin-bottom: 0.03rem;
        }
    .name {
            font-family: PingFangSC, PingFang SC;
            font-weight: 400;
            font-size: 0.24rem;
            line-height: 0.34rem;
            color: #333333;

            &.on {
                font-weight: 500;
                color: #1D69E4;
            }
        }
}
</style>
